// Copyright 叶湘 ( weixin:yexiang841, email:yexiang841@qq.com ), Shitouren Studio. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Hit/Q3D_CPPU_HitType.h"
#include "Property/Q3D_CPPE_PropertyName.h"
#include "Q3D_CPPC_HitTarget.generated.h"

class UQ3D_CPPU_Hit;

/**
 * 
 */
UCLASS(Blueprintable, ClassGroup = (Q3D), meta = (Tooltip = "Hit 目标组件(C++)", BlueprintSpawnableComponent))
class Q3D_LIB_API UQ3D_CPPC_HitTarget : public UActorComponent
{
	GENERATED_BODY()

public:
	// Sets default values for this component's properties
	UQ3D_CPPC_HitTarget();

public:
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Q3D_HitTarget, meta = (Tooltip = "命中映射表，Key 是 ID，Value 是命中"))
	TMap<FName, UQ3D_CPPU_Hit *> Map_Name_To_Ptr_U_Hit;

protected:
	// Called when the game starts
	virtual void BeginPlay() override;

	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;

public:
	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;

public:
	UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = Q3D_HitTarget, meta = (Tooltip = "对 Owner 施加命中"))
	void Q3D_F_Hit_Set(UQ3D_CPPU_Hit *ptr_u_hit, UPARAM(DisplayName = "boool_success") bool &bool_success, UPARAM(DisplayName = "string_log") FString &string_log);

	UFUNCTION(BlueprintCallable, Category = Q3D_HitTarget, meta = (Tooltip = "根据 ID 取消命中"))
	void Q3D_F_Hit_Cancel_ById(FName name_id, UPARAM(DisplayName = "boool_success") bool &bool_success, UPARAM(DisplayName = "string_log") FString &string_log);

	UFUNCTION(BlueprintCallable, Category = Q3D_HitTarget, meta = (Tooltip = "根据命中类型取消命中"))
	void Q3D_F_Hit_Cancel_ByType(EQ3D_CPPE_HitType enum_hit_type, UPARAM(DisplayName = "int_count") int32 &int_count);

	UFUNCTION(BlueprintCallable, Category = Q3D_HitTarget, meta = (Tooltip = "根据命中来源取消命中"))
	void Q3D_F_Hit_Cancel_ByCauser(EQ3D_CPPE_HitType enum_hit_type, AActor *ptr_a_hit_causer, UPARAM(DisplayName = "int_count") int32 &int_count);

	UFUNCTION(BlueprintCallable, Category = Q3D_HitTarget, meta = (Tooltip = "清除 Owner 上的所有同类型命中"))
	void Q3D_F_Hit_Cancel_All(UPARAM(DisplayName = "int_count") int32 &int_count);

protected:
	UFUNCTION(BlueprintCallable, Category = Q3D_HitTarget, meta = (Tooltip = "工具函数，根据 ID 执行删除命中"))
	void _F_Hit_Del_ById(FName name_id, UPARAM(DisplayName = "boool_success") bool &bool_success, UPARAM(DisplayName = "string_log") FString &string_log);

	UFUNCTION(BlueprintCallable, Category = Q3D_HitTarget, meta = (Tooltip = "委托函数，删除命中"))
	void _FD_Hit_Del_ByPtr(UQ3D_CPPU_Hit *ptr_u_hit);
};
